package cn.diancan.util;

import java.text.Collator;  
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;  
import java.util.List;
  
/** 
 * @Title：             SortChineseName.java 
 * @Description:    中文字符排序 
 * @Function:       中文字符排序 
 * @Copyright:      Copyright (c) 2012-11-19 
 * @Author :        zhangzhao 
 * @Version         0.1 
 */  
public class SortChineseText implements Comparator<String>{  
    
    Collator cmp = Collator.getInstance(java.util.Locale.CHINA);  
    
    @Override  
    public int compare(String o1, String o2) {  
        if (cmp.compare(o1 , o2)>0){  
            return 1;  
        }else if (cmp.compare(o1, o2)<0){  
            return -1;  
        }  
        return 0;  
    }  
    
    public static void main(String[] args) {
	List<String> list = new ArrayList<String>();
	list.add("14");
	list.add("13");
	list.add("15");
	list.add("12");
	
	 
	Collections.sort(list, new SortChineseText());  
	for (int i = 0; i < list.size(); i++) {
	    System.out.println(list.get(i));
	}
	
    }
}  